import xlrd, xlwt
import os
import time
import difflib
import json


class ReadExcel(object):
    def __init__(self, data_path, sheetname,):
        #定义一个属性接收文件路径
        self.data_path = data_path
        # 定义一个属性接收工作表名称
        self.sheetname = sheetname
        # 使用xlrd模块打开excel表读取数据
        self.data = xlrd.open_workbook(self.data_path)
        # 根据工作表的名称获取工作表中的内容
        self.table = self.data.sheet_by_name(self.sheetname)
        # 获取工作表的有效行数
        self.rowNum = self.table.nrows

    def getExcelData(self):

        for i in range(1, self.rowNum):
            # 获取单元格数据
            cmd = self.table.cell_value(i, 0)
            body = self.table.cell_value(i, 20)
            quesIndex1 = body.find('question')
            startIndex = body.find('question',quesIndex1+20)
            endIndex =body.find("'",startIndex)
            data = '{"' + body[startIndex:endIndex]
            print(data)
            # print(json.loads(body))






if __name__ == '__main__':
    data_path = '/bigScreenDigitalPeople/result/history/23-10-12_数据分析(准确性时延)/数据分析/数据分析-10.13.xlsx'
    sheetname = '异常数据列表'

    excelObj = ReadExcel(data_path, sheetname)
    excelObj.getExcelData()









